import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { VolunteerVO, VolunteerForm, VolunteerQuery } from '@/api/business/volunteer/types';

/**
 * 查询志愿者详细信息列表
 * @param query
 * @returns {*}
 */

export const listVolunteer = (query?: VolunteerQuery): AxiosPromise<VolunteerVO[]> => {
  return request({
    url: '/business/volunteer/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询志愿者详细信息详细
 * @param userId
 */
export const getVolunteer = (userId: string | number): AxiosPromise<VolunteerVO> => {
  return request({
    url: '/business/volunteer/' + userId,
    method: 'get'
  });
};

/**
 * 新增志愿者详细信息
 * @param data
 */
export const addVolunteer = (data: VolunteerForm) => {
  return request({
    url: '/business/volunteer',
    method: 'post',
    data: data
  });
};

/**
 * 修改志愿者详细信息
 * @param data
 */
export const updateVolunteer = (data: VolunteerForm) => {
  return request({
    url: '/business/volunteer',
    method: 'put',
    data: data
  });
};

/**
 * 删除志愿者详细信息
 * @param userId
 */
export const delVolunteer = (userId: string | number | Array<string | number>) => {
  return request({
    url: '/business/volunteer/' + userId,
    method: 'delete'
  });
};
